<!--
 * @Author: liangkun 2669681641@qq.com
 * @Date: 2023-08-22 13:55:38
 * @LastEditors: liangkun 2669681641@qq.com
 * @LastEditTime: 2023-09-08 18:05:30
 * @FilePath: \radiation-hygiene-fe\src\views\system\ukey\components\resetUkey.vue
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <el-dialog
    title="删除"
    v-if="dialogVisible"
    :visible.sync="dialogVisible"
    width="60%"
  >
    <div class="tableoperation">
			<el-button type="danger" icon="el-icon-delete" size="mini" plain @click="deletes">初始化</el-button>
		</div>

		<el-table v-loading="loading" @selection-change="handleSelectionChange" :data="ukeyLists">
      <el-table-column type="selection" width="50" align="center" />
			<el-table-column label="用户名" align="center" prop="username"/>
			<el-table-column label="锁的版本" align="center" prop="version"/>
			<el-table-column label="拓展版本" align="center" prop="expand_version"/>
			<el-table-column label="启动URl" align="center" prop="startUrl"/>
		</el-table>
  </el-dialog>
</template>

<script>
import { startUrl } from "@/api/system/ukey";
import {debounce} from "@/utils/index"
import cipherDog from '@/utils/cipherDog'
const {Syunew6W} = cipherDog
export default {
  name: 'ResetUkey',
  data() {
    return {
      bindUserTitle: '',
      selectDisabled: false,
      dialogVisible: false,
      ukeyLists: [],
      loading: false
    }
  },
  methods: {
    async openDialog() {
      this.getUkeys()
      this.dialogVisible = true
    },
    deletes() {
      let deleteDevices = this.selection.map(i => i.devicPath)
      try {
        deleteDevices.forEach(async devices => {
          await Syunew6W.resetUKey(devices) // 初始化ukey
          await Syunew6W.setReaderAndWritePass(devices) // 初始化读写密码均为00000000   设置为出厂的FFFFFFFF
        });
      } catch (error) {
        console.log(error);
      }
      this.$message.success('初始化成功')
    },
    async getUkeys() {
      let lists = await Syunew6W.getInfoLists()
      console.log(lists);
      this.ukeyLists = lists
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
			this.selection = selection;
    },
  },
  mounted() {
    Syunew6W.myonLoad(debounce(() => {
      this.getUkeys()
    }, 200))
  }
}
</script>

<style>

</style>